import { Controller, Post, Get, UseInterceptors, UploadedFiles, Body } from '@nestjs/common';
import { DyService } from '@/modules/dy/dy.service';
import { FileFieldsInterceptor } from '@nestjs/platform-express';
import { Express } from 'express';
@Controller("dy")
export class DyController {
  constructor(
    private readonly dyService: DyService
  ) {
  }

  @Get("test")
  test() {
    return this.dyService.test()
  }

  @Post("publish")
  @UseInterceptors(FileFieldsInterceptor([
    { name: 'cover', maxCount: 1 },
    { name: 'video', maxCount: 1 },
  ]))
  publish(@UploadedFiles() files: {cover: Express.Multer.File[], video: Express.Multer.File[]}, @Body() options: any) {
    const opt = {
      videoFile: files.video[0],
      coverFile: files.cover[0],
      config: options
    }
    return this.dyService.publish(opt)
  }

}